package com.digitalchina.lxnsy.fragment;

import android.Manifest;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import androidx.annotation.NonNull;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.recyclerview.widget.LinearLayoutManager;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.apkfuns.logutils.LogUtils;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.bumptech.glide.Glide;
import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.activity.farmTrain.TrainIndexActivity;
import com.digitalchina.lxnsy.activity.farmVideo.HobbiesSelectActivity;
import com.digitalchina.lxnsy.activity.farmVideo.VideoListActivity;
import com.digitalchina.lxnsy.activity.old.ActivityDetailActivity;
import com.digitalchina.lxnsy.activity.old.ActivityListActivity;
import com.digitalchina.lxnsy.activity.old.AgriculturalServiceDetailActivity;
import com.digitalchina.lxnsy.activity.old.AgriculturalServiceListActivity;
import com.digitalchina.lxnsy.activity.old.AgriculturalTrainingDetailsActivity;
import com.digitalchina.lxnsy.activity.old.AnswerListActivity;
import com.digitalchina.lxnsy.activity.old.ConsultDynamicDetailActivity;
import com.digitalchina.lxnsy.activity.old.ConsultDynamicListActivity;
import com.digitalchina.lxnsy.activity.old.ConsultIssueV2Activity;
import com.digitalchina.lxnsy.activity.old.ExpertConsultationActivity;
import com.digitalchina.lxnsy.activity.old.ExpertsDetailActivity;
import com.digitalchina.lxnsy.activity.old.FamousInterviewActivity;
import com.digitalchina.lxnsy.activity.old.FarmingInfoDetailActivity;
import com.digitalchina.lxnsy.activity.old.FarmingInformationActivity;
import com.digitalchina.lxnsy.activity.old.IntegralLotteryActivity;
import com.digitalchina.lxnsy.activity.old.InterviewDetailActivity;
import com.digitalchina.lxnsy.activity.old.PersonnelServiceListActivity;
import com.digitalchina.lxnsy.activity.old.ProductDetailActivity;
import com.digitalchina.lxnsy.activity.old.ProductListActivity;
import com.digitalchina.lxnsy.activity.old.RealTimePriceTabActivity;
import com.digitalchina.lxnsy.activity.old.SelectProductionActivityV2;
import com.digitalchina.lxnsy.activity.old.ShareFarmDetailActivity;
import com.digitalchina.lxnsy.activity.old.ShareFarmListActivity;
import com.digitalchina.lxnsy.activity.old.SheepListActivity;
import com.digitalchina.lxnsy.activity.old.StandardProductionActivity;
import com.digitalchina.lxnsy.activity.old.TalentsDetailsActivity;
import com.digitalchina.lxnsy.activity.old.TechnologiesDetailActivity;
import com.digitalchina.lxnsy.activity.old.TechnologiesListActivity;
import com.digitalchina.lxnsy.activity.old.TechnologyListActivity;
import com.digitalchina.lxnsy.activity.old.TechnologyTrainingVideoListActivityV2;
import com.digitalchina.lxnsy.activity.old.TrainInfoListActivity;
import com.digitalchina.lxnsy.activity.old.WebViewBannerShareActivity;
import com.digitalchina.lxnsy.activity.management.ManagementListActivity;
import com.digitalchina.lxnsy.adapter.HomePageRecyclerAdapter;
import com.digitalchina.lxnsy.api.BusinessAccount;
import com.digitalchina.lxnsy.api.BusinessActivity;
import com.digitalchina.lxnsy.api.BusinessConsultDynamic;
import com.digitalchina.lxnsy.api.BusinessInformation;
import com.digitalchina.lxnsy.api.BusinessPlan;
import com.digitalchina.lxnsy.api.BusinessShareFarm;
import com.digitalchina.lxnsy.api.BusinessTechnologies;
import com.digitalchina.lxnsy.api.BusinessTechnology;
import com.digitalchina.lxnsy.api.BusinessTraining;
import com.digitalchina.lxnsy.base.BaseApplication;
import com.digitalchina.lxnsy.base.BaseV4Fragment;
import com.digitalchina.lxnsy.constant.Constant;
import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.entity.ActivityListVO;
import com.digitalchina.lxnsy.entity.BannerVO;
import com.digitalchina.lxnsy.entity.ConsultDynamicListVO;
import com.digitalchina.lxnsy.entity.ConsultDynamicTypeVO;
import com.digitalchina.lxnsy.entity.FarmingInfoListVO;
import com.digitalchina.lxnsy.entity.HomeShareTypeVO;
import com.digitalchina.lxnsy.entity.ServiceInfoTypeVO;
import com.digitalchina.lxnsy.entity.ShareFarmListVO;
import com.digitalchina.lxnsy.entity.TechnologyVO;
import com.digitalchina.lxnsy.entity.TrainVO;
import com.digitalchina.lxnsy.entity.WeatherVO;
import com.digitalchina.lxnsy.interfaces.IRecyclerType;
import com.digitalchina.lxnsy.service.LocationService;
import com.digitalchina.lxnsy.sy.login.LoginActivity;
import com.digitalchina.lxnsy.sy.login.RegisterAndLoginActivity;
import com.digitalchina.lxnsy.sy.peopleAddExp.ExpertQuestActivity;
import com.digitalchina.lxnsy.sy.peopleAddExp.QuickQuestionActivity;
import com.digitalchina.lxnsy.sy.peopleAddExp.RealTimePriceActivity;
import com.digitalchina.lxnsy.toolkit.FastJsonUtil;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.digitalchina.lxnsy.toolkit.GotoUtil;
import com.digitalchina.lxnsy.toolkit.JointImageUrl;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.digitalchina.lxnsy.toolkit.StringUtil;
import com.digitalchina.lxnsy.toolkit.Utils;
import com.digitalchina.lxnsy.xml.AdminXML;
import com.digitalchina.lxnsy.xml.LocationXML;
import com.digitalchina.lxnsy.xml.UserXML;
import com.facebook.drawee.view.SimpleDraweeView;
import com.jude.easyrecyclerview.EasyRecyclerView;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.lzy.okhttputils.model.HttpParams;
import com.ruffian.library.RTextView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.Bind;
import butterknife.ButterKnife;
import chihane.jdaddressselector.BottomDialog;
import chihane.jdaddressselector.OnAddressSelectedListener;
import chihane.jdaddressselector.model.City;
import chihane.jdaddressselector.model.County;
import chihane.jdaddressselector.model.Province;
import chihane.jdaddressselector.model.Street;
import cn.bingoogolapple.bgabanner.BGABanner;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：APP首页
 * 包名：com.digitalchina.bigdata.activity
 * 创建人：郑皓
 * 创建时间：2017/3/24 11:53:56
 * 修改备注：
 * ================================================
 */

public class MainHomePageV3Fragment extends BaseV4Fragment implements RecyclerArrayAdapter.OnLoadMoreListener, SwipeRefreshLayout.OnRefreshListener, View.OnClickListener, BGABanner.Delegate<ImageView, String>, BGABanner.Adapter<ImageView, String> {

    @Bind(R.id.fragment_home_page_list_recycler_view)
    EasyRecyclerView homePageRecyclerView;

    BGABanner banner;

    private LinearLayout rlExpertConsultation; // 专家咨询
    private LinearLayout rlExpertFastAsk; // 快速提问


    private HomePageRecyclerAdapter adapter;

    private View headView;//头布局

    private List<IRecyclerType> allList = new ArrayList<>();

    private List<ConsultDynamicListVO> consultDynamicListVOList = new ArrayList<>();
    private List<ActivityListVO> activityVOList = new ArrayList<>();
//    private List<ShareFarmListVO> shareVOList = new ArrayList<>();
    private List<FarmingInfoListVO> shareVOList = new ArrayList<>();

    private int msgWhat;

    private List<BannerVO> bannerVOList = new ArrayList<>();

    //LBS
    private final int SDK_PERMISSION_REQUEST = 127;


    private LinearLayout tvJsdq, tvZthd, tvGxsn;


    private LinearLayout rlVideo;
    private LinearLayout rlPrice;
    private LinearLayout rlTalents;


    @Override
    public View setRootView() {
        return inflate(R.layout.fragment_home_page);
    }

    @Override
    public void initMember() {
//        showActionBar();
//        setTitle("首页");
        hideActionBar();
        headView = LayoutInflater.from(getActivity()).inflate(R.layout.view_headview_home_page_v3, null);


        banner = headView.findViewById(R.id.headview_home_page_banner);
        rlExpertConsultation = headView.findViewById(R.id.headview_home_page_tv_expert_consultation);
        rlExpertFastAsk = headView.findViewById(R.id.headview_home_page_tv_fast_ask);
        rlVideo = headView.findViewById(R.id.rl_video);
        rlPrice = headView.findViewById(R.id.rl_price);
        rlTalents = headView.findViewById(R.id.rl_talents);
      //  rlInterview = headView.findViewById(R.id.rl_interview);

        //新增四个模块
        tvJsdq = headView.findViewById(R.id.tv_jsdq);
        tvZthd = headView.findViewById(R.id.tv_zthd);

        tvGxsn = headView.findViewById(R.id.tv_gxsn);

        homePageRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        adapter = new HomePageRecyclerAdapter(getActivity());

        homePageRecyclerView.setAdapter(adapter);

        adapter.addHeader(new RecyclerArrayAdapter.ItemView() {
            @Override
            public View onCreateView(ViewGroup parent) {

                return headView;
            }

            @Override
            public void onBindView(View headerView) {


            }
        });

        getPersimmions();
        initBanner();
        onRefresh();
    }


    @TargetApi(23)
    private void getPersimmions() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            ArrayList<String> permissions = new ArrayList<>();
            /***
             * 定位权限为必须权限，用户如果禁止，则每次进入都会申请
             */
            // 定位精确位置
            if (getActivity().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                permissions.add(Manifest.permission.ACCESS_FINE_LOCATION);
            }
            if (getActivity().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                permissions.add(Manifest.permission.ACCESS_COARSE_LOCATION);
            }

            if (permissions.size() > 0) {
                requestPermissions(permissions.toArray(new String[permissions.size()]), SDK_PERMISSION_REQUEST);
            }
        }
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @TargetApi(23)
    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);


    }

    /**
     * 获取热门回答列表(农技智库列表)
     */
    public void getTechnology() {
        BusinessTechnology.getTechnologyList(getActivity(), "", String.valueOf(1), String.valueOf(3), mHandler);
    }

    @Override
    public void addListener() {

        homePageRecyclerView.setRefreshListener(this);

        adapter.setError(R.layout.view_error, new RecyclerArrayAdapter.OnErrorListener() {
            @Override
            public void onErrorShow() {
                adapter.resumeMore();
            }

            @Override
            public void onErrorClick() {
                adapter.resumeMore();
            }
        });

        adapter.setOnItemClickListener(new RecyclerArrayAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                int viewType = adapter.getItem(position).type();
                if (viewType == Constant.ITEM_TYPE_SERVICE_TYPE) {//农事服务列表查看更多
                    GotoUtil.gotoActivity(getActivity(), FarmingInformationActivity.class);
                } else if (viewType == Constant.ITEM_TYPE_SERVICE_LIST) {//查看农事服务详情
                    FarmingInfoListVO vo = (FarmingInfoListVO) adapter.getItem(position);
//                    String url = URL.SERVER + vo.getH5Url().substring(1);
                    GotoUtil.gotoActivity(getActivity(), FarmingInfoDetailActivity.class, false, "FarmingInfoListVO", vo);
                } else if (viewType == Constant.ITEM_TYPE_TRAIN_TYPE) {//培训信息列表查看更多
                    GotoUtil.gotoActivity(getActivity(), TrainInfoListActivity.class);
                } else if (viewType == Constant.ITEM_TYPE_TRAIN_LIST) {//查看培训详情
                    TrainVO vo = (TrainVO) adapter.getItem(position);
                    GotoUtil.gotoActivity(getActivity(), AgriculturalTrainingDetailsActivity.class, false, "toTrainDetails", vo);
                } else if (viewType == Constant.ITEM_TYPE_HOT_ANSWER_TYPE) {//热门回答列表查看更多
                    GotoUtil.gotoActivity(getActivity(), TechnologyListActivity.class);
                } else if (viewType == Constant.ITEM_TYPE_HOT_ANSWER_LIST) {//查看热门回答详情
                    GotoUtil.gotoActivity(getActivity(), AnswerListActivity.class, "TechnologyVO", adapter.getItem(position));
                } else if (viewType == Constant.ITEM_TYPE_TECHNOLOGIES_TYPE) {//技术大全更多
                    GotoUtil.gotoActivity(getActivity(), TechnologiesListActivity.class);
                } else if (viewType == Constant.ITEM_TYPE_TECHNOLOGIES_LIST) {//技术大全列表
                    GotoUtil.gotoActivity(getActivity(), TechnologiesDetailActivity.class, "TechnologiesVO", adapter.getItem(position));
                } else if (viewType == Constant.ITEM_TYPE_CONSULT_TYPE) {//咨询动态更多
                    GotoUtil.gotoActivity(getActivity(), ConsultDynamicListActivity.class);

                    //  noLoginToSkip(ConsultDynamicListActivity.class);

//                    GotoUtil.gotoActivity(getActivity(), ConsultDynamicListActivity.class);
                } else if (viewType == Constant.ITEM_TYPE_CONSULT_LIST) {//咨询动态列表
                    if ("1".equals(UserXML.getLoginStatus(getActivity()))) {
                        GotoUtil.gotoActivity(getActivity(), ConsultDynamicDetailActivity.class, "consultDynamicListVO", adapter.getItem(position));
                    } else {
                        GotoUtil.gotoActivity(getActivity(), LoginActivity.class);
                    }
                } else if (viewType == Constant.ITEM_TYPE_ACTIVITY_TYPE) {
                    GotoUtil.gotoActivity(getActivity(), ActivityListActivity.class);
                } else if (viewType == Constant.ITEM_TYPE_ACTIVITY_LIST) {
                    ActivityListVO vo = (ActivityListVO) adapter.getItem(position);
                    GotoUtil.gotoActivity(getActivity(), ActivityDetailActivity.class, "ActivityVO", vo);
                }else if (viewType == Constant.ITEM_TYPE_SHARE_LIST) {
                    GotoUtil.gotoActivity(getActivity(), ShareFarmDetailActivity.class, "ShareFarmListVO", adapter.getAllData().get(position));
                }else if (viewType == Constant.ITEM_TYPE_SHARE_TYPE) {//

                    GotoUtil.gotoActivity(getActivity(), FarmingInformationActivity.class);


                }
            }
        });

        rlExpertConsultation.setOnClickListener(this);//专家咨询
        rlExpertFastAsk.setOnClickListener(this);//快速提问

        rlVideo.setOnClickListener(this);
        rlPrice.setOnClickListener(this);
        rlTalents.setOnClickListener(this);


        tvJsdq.setOnClickListener(this);
        tvZthd.setOnClickListener(this);
        tvGxsn.setOnClickListener(this);


        banner.setDelegate(this);
    }

    @Override
    public void setHandler() {
        mHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                msgWhat = msg.what;
                if (homePageRecyclerView == null) {
                    return;
                }
                if (homePageRecyclerView.getSwipeToRefresh().isRefreshing())
                    homePageRecyclerView.setRefreshing(false);
                LogUtils.e("请求结果"+msg.what);
                switch (msg.what) {
                    case MSG.MSG_GET_TRAINING_IN_CITY_SUCCESS:
                        callBack(msg.obj);
                        break;
                    case MSG.MSG_TECHNOLOGY_LIST_SUCCESS:
                        callBack(msg.obj);
                        break;
                    case MSG.MSG_TECHNOLOGIES_SUCCESS: //技术大全
                        callBack(msg.obj);
                        break;
                    case MSG.MSG_QUERY_CONSULT_LIST_SUCCESS: //咨询动态
                        callBack(msg.obj);
                        break;
                    case MSG.MSG_SEARCH_ACTIVITY_SUCCESS: // 热门活动
                        callBack(msg.obj);
                        break;
                    case MSG.MSG_SHARE_FARM_LIST_SUCCESS: // 共享三农
                        callBack(msg.obj);
                        break;
                    case MSG.MSG_GET_PLAN_COUNT_BY_USER_SUCCESS: // 获取种植标准数量
                        String count = FastJsonUtil.getString(msg.obj.toString(), "count");
                        if (!StringUtil.isStrEmpty(count)) {
                            if (Integer.parseInt(count) <= 0)
                                GotoUtil.gotoActivity(getActivity(), SelectProductionActivityV2.class);
                            else
                                GotoUtil.gotoActivity(getActivity(), StandardProductionActivity.class);
                        } else
                            showToast("获取数据失败");
                        break;
                    case MSG.MSG_GET_PLAN_COUNT_BY_USER_FIELD:
                        showToast(msg.obj.toString());
                        break;
                    case MSG.MSG_CHECK_USER_PERMISSON_SUCCESS: // 是否有企业权限
                        String s = FastJsonUtil.getString(msg.obj.toString());
                        break;
                    case MSG_S_0: // 是否选过类型
                        String isSelect = FastJsonUtil.getString(msg.obj.toString(), "isSelect");
                        if ("1".equals(isSelect)) {
                            UserXML.setVal(getActivity(), "isSelectType", "1");
                            GotoUtil.gotoActivity(getActivity(), VideoListActivity.class);
                        } else {
                            GotoUtil.gotoActivity(getActivity(), HobbiesSelectActivity.class);
                        }
                        break;
                }
            }
        };
    }

    @Override
    public void callBack(Object object) {

        switch (msgWhat) {

            case MSG.MSG_QUERY_CONSULT_LIST_SUCCESS://咨询动态

                consultDynamicListVOList = FastJsonUtil.getListBeanRow(object.toString(), "rows", ConsultDynamicListVO.class);
                adapter.clear();
                allList.clear();

                allList.add(new FarmingInfoListVO());
                if (shareVOList != null) {
                    allList.addAll(shareVOList);
                }


                allList.add(new ConsultDynamicTypeVO());
                if (consultDynamicListVOList != null) {
                    allList.addAll(consultDynamicListVOList);
                }
                allList.add(new ConsultDynamicListVO());
                if (activityVOList != null) {
                    allList.addAll(activityVOList);
                }
                adapter.addAll(allList);

                break;
            case MSG.MSG_SEARCH_ACTIVITY_SUCCESS:// 热门活动

                activityVOList = FastJsonUtil.getListBeanRow(object.toString(), "rows", ActivityListVO.class);
                adapter.clear();
                allList.clear();


                allList.add(new FarmingInfoListVO());
                if (shareVOList != null) {
                    allList.addAll(shareVOList);
                }


                allList.add(new ConsultDynamicTypeVO());
                if (consultDynamicListVOList != null) {
                    allList.addAll(consultDynamicListVOList);
                }
                allList.add(new ConsultDynamicListVO());
                if (activityVOList != null) {
                    allList.addAll(activityVOList);
                }
                adapter.addAll(allList);

                break;
            case MSG.MSG_GET_INFOMATION_LIST_BY_TYPE_SUCCESS://共享精选

                shareVOList = FastJsonUtil.getListBeanRow(object.toString(), "rows", FarmingInfoListVO.class);
                adapter.clear();
                allList.clear();


                allList.add(new FarmingInfoListVO());
                if (shareVOList != null) {
                    allList.addAll(shareVOList);
                }


                allList.add(new ConsultDynamicTypeVO());
                if (consultDynamicListVOList != null) {
                    allList.addAll(consultDynamicListVOList);
                }
                allList.add(new ConsultDynamicListVO());
                if (activityVOList != null) {
                    allList.addAll(activityVOList);
                }
                adapter.addAll(allList);

                break;
        }

    }

    /**
     * 设置顶部轮播图 - 本地资源
     */
    private void initBanner() {

        banner.setAdapter(this);
        banner.setData(R.drawable.banner1);
        banner.setCurrentItem(0);
    }

    @Override
    public void rightOnClick() {

    }

    @Override
    public void startActivityForResult(Intent intent, int requestCode) {
        super.startActivityForResult(intent, requestCode);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {

            case R.id.headview_home_page_tv_expert_consultation:
                //专家咨询
                noLoginToSkip(ExpertQuestActivity.class);
                break;
            case R.id.rl_video:
                //农科大讲堂
                GotoUtil.gotoActivity(getActivity(), TechnologyTrainingVideoListActivityV2.class);
                break;
            case R.id.rl_price:
                //实时价格
                GotoUtil.gotoActivity(getActivity(), RealTimePriceActivity.class);

              //  noLoginToSkip(RealTimePriceActivity.class);
                break;
            case R.id.tv_jsdq: // 技术大全
                GotoUtil.gotoActivity(getActivity(), TechnologiesListActivity.class);
                break;
            case R.id.tv_zthd: // 专题活动
                GotoUtil.gotoActivity(getActivity(), ActivityListActivity.class);
                break;

            case R.id.tv_gxsn: // 共享三农
                GotoUtil.gotoActivity(getActivity(), ShareFarmListActivity.class);
                break;
//            case R.id.rl_interview://两种羊供需
//
//
//                GotoUtil.gotoActivity(getActivity(), SheepListActivity.class);
//                break;
            case R.id.rl_talents:
                //人才服务-农活帮



                  GotoUtil.gotoActivity(getActivity(), PersonnelServiceListActivity.class);
                break;
            case R.id.headview_home_page_tv_fast_ask:
                //快速提问
                noLoginToSkip(QuickQuestionActivity.class);
                break;
        }
    }


    @Override
    public void onRefresh() {
        //热点资讯====农业资讯
        BusinessInformation.getInformationListByType(getActivity(), "", 1, 3,"1", mHandler);

        // 咨询动态
        BusinessConsultDynamic.queryConsultList(getActivity(), 1, 3,"1", mHandler);
        //热门活动
        BusinessActivity.searchActivity(getActivity(), "", "", "", 1, 2,"1", mHandler);
        // 共享三农
        BusinessShareFarm.shareList(getActivity(), 1, 3, "", "", "1",mHandler);
    }

    @Override
    public void onLoadMore() {

    }

    @Override
    public void onStart() {
        super.onStart();
    }

    @Override
    public void onStop() {
        super.onStop();
    }


    @Override
    public void onBannerItemClick(BGABanner banner, ImageView itemView, String model, int position) {

        if (bannerVOList == null || bannerVOList.size() <= 0)
            return;

        Map<String, String> map = new HashMap<>();
                /*
                  获取首页banner
                  0/无需跳转
                  1/商品详情
                  2/农事详情
                  3/专家详情
                  4/视频详情
                  5/培训详情
                  6/专访详情
                  7/人才需求详情
                  8/人力供应详情
                  9/价格列表
                  10/商品列表
                  11/农事列表
                  12/专家列表
                  13/视频列表
                  14/培训列表
                  15/本期名家列表
                  16/往期名家列表
                  17/人才需求列表
                  18/人力供应列表
                  19/跳转网页
                  20/快速提问
                 */
        switch (bannerVOList.get(position).getType()) {
            case 0:

                break;
            case 1:
                GotoUtil.gotoActivity(getActivity(), ProductDetailActivity.class, "productId", bannerVOList.get(position).getAddressid());
                break;
            case 2:
                GotoUtil.gotoActivity(getActivity(), AgriculturalServiceDetailActivity.class, "bannerId", bannerVOList.get(position).getAddressid());
                break;
            case 3:
                GotoUtil.gotoActivity(getActivity(), ExpertsDetailActivity.class, "id", bannerVOList.get(position).getAddressid());
                break;
            case 4: // 视频大讲堂详情 暂时无法实现
                // GotoUtil.gotoActivity(getActivity(), TechnologyTrainingVideoDetailNewActivity.class, "id", bannerVOList.get(position).getAddressid());
                break;
            case 5:
                GotoUtil.gotoActivity(getActivity(), AgriculturalTrainingDetailsActivity.class, "JPush_attention", bannerVOList.get(position).getAddressid());
                break;
            case 6:
                GotoUtil.gotoActivity(getActivity(), InterviewDetailActivity.class, "bannerId", bannerVOList.get(position).getAddressid());
                break;
            case 7:
                map.put("bannerId", bannerVOList.get(position).getAddressid());
                map.put("type", "0");
                GotoUtil.gotoActivity(getActivity(), TalentsDetailsActivity.class, "map", map);
                break;
            case 8:
                map.put("bannerId", bannerVOList.get(position).getAddressid());
                map.put("type", "1");
                GotoUtil.gotoActivity(getActivity(), TalentsDetailsActivity.class, "map", map);
                break;
            case 9:
                GotoUtil.gotoActivity(getActivity(), RealTimePriceTabActivity.class);
                break;
            case 10:
                GotoUtil.gotoActivity(getActivity(), ProductListActivity.class);
                break;
            case 11:
                GotoUtil.gotoActivity(getActivity(), AgriculturalServiceListActivity.class);
                break;
            case 12:
                GotoUtil.gotoActivity(getActivity(), ExpertConsultationActivity.class);
                break;
            case 13:
                GotoUtil.gotoActivity(getActivity(), TechnologyTrainingVideoListActivityV2.class);
                break;
            case 14:
                GotoUtil.gotoActivity(getActivity(), TrainInfoListActivity.class);
                break;
            case 15:
                GotoUtil.gotoActivity(getActivity(), FamousInterviewActivity.class);
                break;
            case 16:
                GotoUtil.gotoActivity(getActivity(), FamousInterviewActivity.class);
                break;
            case 17:
                GotoUtil.gotoActivity(getActivity(), PersonnelServiceListActivity.class);
                break;
            case 18:
                GotoUtil.gotoActivity(getActivity(), PersonnelServiceListActivity.class);
                break;
            case 19:
                GotoUtil.gotoActivity(getActivity(), WebViewBannerShareActivity.class, "bannerVO", bannerVOList.get(position));
                break;
            case 20:
                noLoginToSkip(ConsultIssueV2Activity.class);
                break;
        }
    }

    @Override
    public void fillBannerItem(BGABanner banner, ImageView itemView, String model, int position) {
        Glide.with(itemView.getContext())
                .load(model)
                .placeholder(R.drawable.bg_default)
                .error(R.drawable.bg_default)
                .dontAnimate()
                .centerCrop()
                .into(itemView);
    }

    public void gotoLottery() {
        GotoUtil.gotoActivity(getActivity(), IntegralLotteryActivity.class);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
